(1) Field of the Invention
The present invention relates to a method and an apparatus for appending records, and more particularly, to a method and apparatus of this kind by which an effective last update point of a file including end-of-file information at an end thereof is reliably retained when new data of variable length is appended to the file.
(2) Description of the Related Art
In a database system, for example, a log file is used to save historical information such as update data, and each time a user performs an operation, historical information indicating such operation is sequentially appended to (added to the end of) the log file. When information is appended to the log file, the location in the file where the information is to be written, that is, the end point of effective data in the file, is identified, and the information is written subsequently to the end point.
FIGS. 11(A) and 11(B) illustrate, by way of example, a conventional method of appending records to a file. As seen from the file structure shown in FIG. 11(A), a file 1 is composed of data 2, and end-of-file (EOF) information 3 specifying the effective range of the data 2 from the beginning of the file 1 to the end of the data 2. Thus, when reading the data, the file 1 is read from the beginning thereof, and upon detection of the end-of-file information 3 indicating the end of the file 1, it is judged that the file 1 has been read through to the end of the data 2.
FIG. 11(B) illustrates the structure of a file 1a to which data has been appended. New data 2a is written immediately subsequent to the existing data 2, that is, from the location where the end-of-file information 3 exists, and end-of-file information 3a is written following the end of the appended data 2a.
In the conventional record storing method in which end-of-file information is written at the end of effective data, however, if the system unexpectedly goes down due to, for example, power outage, while data is being appended and end-of-file information is not yet written, a file with no end-of-file information can possibly be created. Also in cases where the storage area runs short while data is appended, a file with no end-of-file information can be created because the data can only partially be written. Even if such a file with no end-of-file information can be read later, the end point of the file, that is, the last update point of the data, cannot be identified because the end-of-file information cannot be detected. It is, therefore, impossible to determine the range of correct data.